// components/color/color.js
Component({
  options: {
    styleIsolation: "isolated"
  },
  observers: {
    "currentRGB": function(newCurrentRGB) {
      let arrayRGB = newCurrentRGB.split(",")
      this.setData({
        rgb: [...this.data.rgb, newCurrentRGB],
        R: arrayRGB[0] + ",0,0",
        G: "0," + arrayRGB[1] + ",0",
        G: "0,0," + arrayRGB[2]
      })
      console.log(this.data)
    }
  },
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    rgb : [],
    R: "255,0,0",
    G: "0,255,0",
    B: "0,0,255",
    currentRGB: ""
  },

  /**
   * 组件的方法列表
   */
  methods: {
    clickAddView() {
      this.setData({
        currentRGB: (Math.random()*255).toFixed(0) + "," + (Math.random()*255).toFixed(0) + "," + (Math.random()*255).toFixed(0)
      })
    }
  },
  pageLifetimes: {
    show() {
      this.setData({
        rgb : [(Math.random()*255).toFixed(0) + "," + (Math.random()*255).toFixed(0) + "," + (Math.random()*255).toFixed(0)],
      })
    },
    hide() {
      console.log("hide")
    },
    resize() {
      console.log("页面尺寸变化")
    }
  },

})
